﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Domain.IServices.WarehouseManagement;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.WarehouseManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InventoryManagementController : ControllerBase
    {
        private readonly IInventoryManagementServices _InventoryManagementServices;
        public InventoryManagementController(IInventoryManagementServices InventoryManagementServices)
        {
            _InventoryManagementServices = InventoryManagementServices;
        }

        /// <summary>
        /// 新增盘点单
        /// </summary>
        /// <param name="inventoryManagement"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddInventoryManagement([FromBody]InventoryManagement inventoryManagement)
        {
            return await _InventoryManagementServices.AddInventoryManagement(inventoryManagement);
        }
        
        /// <summary>
        /// 盘点单的显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<InventoryManagement>> GetAllInventoryManagement(string? taskCode, int? status, int pageIndex = 1, int pageSize = 5)
        {
           return await _InventoryManagementServices.GetAllInventoryManagement(taskCode, status, pageIndex, pageSize);
        }

        /// <summary>
        /// 盘点单的修改
        /// </summary>
        /// <param name="inventoryManagement"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateInventoryManagement([FromBody] InventoryManagement inventoryManagement)
        {
            return await _InventoryManagementServices.UpdateInventoryManagement(inventoryManagement);
        }

        /// <summary>
        /// 删除盘点单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> DeleteInventoryManagement(int id)
        {
            return await _InventoryManagementServices.DeleteInventoryManagement(id);
        }
    }
}
